import sys

from PyQt5.QtWidgets import QApplication

from admin.video_thread import video_thrad


class admin():
    app = QApplication(sys.argv)
    video_therad = None
    __UI = {}

    def __init__(self):
        self.video_therad = video_thrad(self)
        self.video_therad.start()

    def __del__(self):
        self.video_therad.exit_run()

    def getUI(self, UI):
        ui_name = str(UI).split('\'')[1]
        if ui_name not in self.__UI:
            self.__UI[ui_name] = UI(self)

        return self.__UI[ui_name]

    def deleteUI(self, UI):
        ui_name = str(UI).split('\'')[1]
        if ui_name in self.__UI:
            del self.__UI[ui_name]
        return None

    def exec(self):
        self.app.exec()
